(function(){
	//获取应用上下文
		var contextPath = function(){
			var contextPath = document.location.pathname;
			var index =contextPath.substr(1).indexOf("/"); 
			contextPath = contextPath.substr(0,index+1);
			delete index;
			return contextPath; 
		};
		var getAbsolutePath = function(path){
				var absolutePath = [];
				absolutePath.push(window.location.protocol);
				absolutePath.push("//");
				absolutePath.push(window.location.host);
				absolutePath.push(contextPath());
				absolutePath.push(path);
				return absolutePath.join('');
		};
		
		/**
		 * 
		 * 为jquery扩展一个方法来通过jquery获取url参数，
		 * 如： $.getUrlParam('key')
		 * */
		 (function ($) {
                $.getUrlParam = function (name) {
                    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                    var r = window.location.search.substr(1).match(reg);
                    if (r != null) return unescape(r[2]); return null;
                };
            })(jQuery);
		
		window.url = {
				SONG_LIST : getAbsolutePath('/song/list'),
				MY_SONG : getAbsolutePath('/song/mySong'),
				TEST : getAbsolutePath('/song/test'),
				SAVE_SONG : getAbsolutePath('/song/saveSong'),
				NEW_SONG : getAbsolutePath('/system/song/add'),
				CONVERT : getAbsolutePath('/system/song/convert'),
				LYRIC : getAbsolutePath('/song/lyric'),
				INCREASE : getAbsolutePath('/song/increase'),
				MAIN : getAbsolutePath('/index.html'),
				LIST_SONG : getAbsolutePath('/song/songList.html'),
				LOGIN : getAbsolutePath('/login'),
				USER_LIST : getAbsolutePath('/admin/user'),
				DELETE_SONG : function(id){
					return getAbsolutePath('/song/delete/'+id);
				},
				DELETE_SONG_PAGE : function(id){
					return getAbsolutePath('/song/songList.html?id='+id);
				},
				UPDATE_SONG_PAGE : function(id){
					return getAbsolutePath('/song/updateSong.html?id='+id);
				},
				UPDATE_SONG : function(id){
					return getAbsolutePath('/song/update/'+id);
				},
				SONG : function(id){
					return getAbsolutePath('/song/get/'+id);
				},
				UPLOAD_MP3:getAbsolutePath('/system/song/upload/mp3'),
				UPLOAD_IMG:getAbsolutePath('/system/song/upload/img'),
				UPLOAD_LYR:getAbsolutePath('/system/song/upload/lyr')
		};
})();

//window.url.SONG_LIST = http://localhost:8080/PracticalTraining/song/saveSong?songName = 发如雪 & userName = admin